<?php
defined('IN_XLP') or exit('Access Denied');
$Document = array(
    'pageid'   => 'task-index', //页面标示
    'pagename' => '任务列表', //当前页面名称
    'mycss'    => array('../jquery-ui/css/smoothness/jquery-ui-1.10.0.custom.min'), //加载的css样式表
    'myjs'     => array('../jquery-ui/js/jquery-ui-1.10.0.custom.min', '../jquery-ui/js/jquery-ui-timepicker-addon'), //加载的js脚本
    'footerjs' => array(),
    'head'     => true, //加载头部文件
);
include getTpl('header', 'public');
?>
<style>
tr th,tr td{text-align:center}
tr td img{border-radius:30px}
.txl{text-align:left}
.w14{width:14% !important;}
.red{color:red;}
.pointer{cursor:pointer;}
.underline{text-decoration:underline;font-weight:bold;}
</style>
<!--顶部导航 开始-->
<?php include getTpl('top', 'public');?>
<!--顶部导航 结束-->
<!--左侧菜单 开始-->
<?php include getTpl('nav', 'public');?>
<!--左侧菜单 结束-->
<!--主体 开始-->
<!-- content -->
<section id="content">
	<!-- main padder -->
	<section class="main padder">
		<div class="clearfix">
			<h4><i class="fa fa-table"></i>任务列表</h4>
			<section class="panel">
					<div class="panel-body">
						<div class="row text-small">
							<form action="<?php echo U('task/index'); ?>" method="get">
								<input type="hidden" name="g" value="content">
								<input type="hidden" name="c" value="task">
								<input type="hidden" name="m" value="index">
								<!-- <div class="col-sm-2 w14">
									<label for="">开始时间 <input class="input-sm" name="starttime" id="starttime" size="16" type="text" value="<?php //echo $starttime; ?>" readonly ></label>
								</div>
								<div class="col-sm-2 w14">
									<label for="">结束时间 <input class="input-sm" name="endtime" id="endtime" size="16" type="text" value="<?php //echo $endtime; ?>" readonly ></label>
								</div> -->
								<div class="col-sm-2 w14">
									<div class="input-group">
										<input type="text" class="input-sm form-control" placeholder="任务名称" name="keyword" id="keyword" value="<?php echo $keyword; ?>">
										<span class="input-group-btn">
											<button class="btn btn-sm btn-white" type="submit">搜索</button>
										</span>
									</div>
								</div>
								<div class="col-sm-2">
									<div class="input-group">
										<!-- <a class="btn btn-sm btn-white" href="<?php //echo U('task/index',array('export'=>1,'starttime'=>$starttime,'endtime'=>$endtime,'keyword'=>$keyword)); ?>">导出CSV</a> -->
										<a class="btn btn-sm btn-white" href="<?php echo U('task/index'); ?>">搜索重置</a>
										<a style="margin-left:35px;" class="btn btn-sm btn-white" href="<?php echo U('task/sort'); ?>" rel="pop">任务排序</a>
									</div>
								</div>
							</form>
						</div>
					</div>

					<div class="table-responsive">
						<table class="table table-striped b-t text-small">
							<thead>
								<tr>
									<th width="80">任务ID</th>
									<th width="">任务标题</th>
									<th width="">发布人</th>
									<th width="70">UID</th>
									<th width="">奖品名称</th>
									<th width="">奖品总数</th>
									<th width="">剩余奖品</th>
									<th width="">参与人数</th>
									<th width="">有效阅读</th>
									<th width="">开始时间</th>
									<th width="">结束时间</th>
									<th width="80">状态</th>
									<th width="100">操作</th>
								</tr>
							</thead>
							<tbody>
								<?php foreach ($task_list as $k => $v): ?>
								<tr>
									<td><?php echo $v['id'] ?></td>
									<td><?php echo $v['task_title'] ?></td>
									<td><?php echo $v['poster_name'] ?></td>
									<td><?php echo $v['poster_uid'] ?></td>
									<td><?php echo $v['reward_name']?></td>
									<td><?php echo $v['reward_total'] ?></td>
									<td><?php echo $v['reward_left'] ?></td>
									<td>
										<a class="underline" target="_blank" href="<?php echo U('task/statistic',array('id'=>$v['id'])) ?>">
										<?php echo $v['partin_num'] ?>
										</a>
									</td>
									<td><?php echo $v['promotion_time'] ?></td>
									<td><?php echo $v['time_start'] ?></td>
									<td><?php echo $v['time_end'] ?></td>
									<td><?php echo $v['state'] ?></td>
									<td>
                                        <div class="btn-group">
                                            <button class="btn btn-white btn-xs dropdown-toggle" data-toggle="dropdown">操作<span class="caret"></span></button>
                                            <ul class="dropdown-menu">
                                                <li><a target="_blank" href="<?php echo U('task/edit',array('id'=>$v['id'])) ?>">编辑</a></li>
                                                <li><a class="pointer" onClick="del_task(<?php echo $v['id'] ?>, this)">删除</a></li>
                                            </ul>
                                        </div>
                                    </td>
								</tr>
								<?php endforeach ?>
							</tbody>
						</table>
					</div>
					
					<footer class="panel-footer">
						<div class="row">
							<div class="col-sm-12 text-right text-center-sm">
								<?php echo page($total,$page,'', 20, 'page');?>
							</div>
						</div>
					</footer>

				</div>
			</section>
		</div>
	</section>
	<!--/ main padder -->
</section>
<!--/ content -->
<!--主体 结束-->
<script>
function del_task(task_id, obj) {
	if(!confirm('真的要删除此任务吗？')) return false;
	$.post('<?php echo U("task/del") ?>', {"id":task_id}, function(result){
		if(result.status==1) {
			// $(obj).parents('tr').hide();
			self.location.reload();
		} else {
			Msg.error(result.info);
		}
	}, 'JSON');
}
$(function(){
	$('#starttime').datetimepicker();
	$('#endtime').datetimepicker();

});
</script>
<?php include getTpl('footer', 'public'); ?>